package com.ankicoo.phonograph.controller;

import com.ankicoo.auth.entity.AuthUserPO;
import com.ankicoo.common.response.ResponseBody;
import com.ankicoo.database.configuration.DataSource;
import com.ankicoo.database.constant.DataSourceConst;
import com.ankicoo.database.service.DataBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * Description:
 *
 * @author : QCYANG
 * @date : 2022/1/5 16:55
 */
@RestController
@RequestMapping("/qcyang")
public class TestController {
    @Autowired
    private DataBaseService dbService;

    @GetMapping("/userList")
    @DataSource(DataSourceConst.DATA_SOURCE_CENTER)
    public ResponseBody<List<AuthUserPO>> getUserList(){
        List<AuthUserPO> objects = dbService.selectAll(AuthUserPO.class);
        return ResponseBody.createBySuccess(objects);
    }

    @GetMapping("/index")
    public ModelAndView getIndex(){
        ModelAndView view = new ModelAndView("world.html");
        return view;
    }
}
